<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="renderer" content="webkit"/>
  <meta name="force-rendering" content="webkit"/>
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"/>
  <title>基本设置</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <link rel="stylesheet" href="/bower_components/bootstrap/dist/css/bootstrap.min.css">
  <link rel="stylesheet" href="/bower_components/font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" href="/bower_components/Ionicons/css/ionicons.min.css">
  <link rel="stylesheet" href="/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
  <link rel="stylesheet" href="/dist/css/AdminLTE.min.css">
  <link rel="stylesheet" href="/dist/css/skins/_all-skins.min.css">

  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->

  <!-- Google Font -->
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

  <!--头部-->
  <header id="headerDiv" class="main-header">
    <!--#include  file="/pages/admin/header.html"-->
  </header>

  <!--左侧边栏 -->
  <aside id="sidebarDiv" class="main-sidebar">
    <!--#include  file="/pages/admin/sidebar.html"-->
  </aside>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        基本设置
      </h1>
      <ol class="breadcrumb">
        <li><a href="javascript:void(0);"><i class="fa fa-dashboard"></i> 基本设置</a></li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">
      <div class="row">
        <div class="col-xs-12">
          <div class="nav-tabs-custom">
            <ul class="nav nav-tabs">
              <li class="active"><a href="#basic" data-toggle="tab">基本设置</a></li>
              <li><a href="#serve" data-toggle="tab">服务器设置</a></li>
              <li><a href="#kou" data-toggle="tab">扣量设置</a></li>
            </ul>
            <div class="tab-content">
              <div class="active tab-pane" id="basic">
                <form class="form-horizontal">
                  <div class="form-group">
                    <label for="sysName" class="col-sm-2 control-label">系统名称</label>
                    <div class="col-sm-6">
                      <input type="text" class="form-control" id="sysName">
                    </div>
                    <div class="col-sm-4">
                      <p class="help-block">首页和低部或是其它地方出现的联盟名称</p>
                    </div>

                  </div>

                  <div class="form-group">
                    <label  class="col-sm-2 control-label">新增网站</label>

                    <div class="col-sm-6">
                      <label class="radio-inline">
                        <input  name="addSite" type="radio" value="0" checked>人工审核</label>
                      <label class="radio-inline">
                        <input name="addSite" type="radio" value="1">自动通过</label>
                    </div>
                  </div>
                  <!--<div class="form-group">-->
                    <!--<label class="col-sm-2 control-label">新增网站</label>-->

                    <!--<div class="col-sm-6">-->
                      <!--<div class="radio">-->
                        <!--<label>-->
                          <!--<input type="radio" name="addSite" id="optionsRadios1" value="0">-->
                          <!--人工审核-->
                        <!--</label>-->
                      <!--</div>-->
                      <!--<div class="radio">-->
                        <!--<label>-->
                          <!--<input type="radio" name="addSite" id="optionsRadios2" value="1">-->
                          <!--自动通过-->
                        <!--</label>-->
                      <!--</div>-->

                    <!--</div>-->
                  <!--</div>-->
                  <div class="form-group">
                    <label for="register" class="col-sm-2 control-label">24小时允许注册</label>

                    <div class="col-sm-6">
                      <input type="text" class="form-control" id="register">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="pvStep" class="col-sm-2 control-label">pv步长</label>

                    <div class="col-sm-6">
                      <input type="text" class="form-control" id="pvStep">
                    </div>
                  </div>

                  <div class="form-group">
                    <label  class="col-sm-2 control-label">域名限制</label>

                    <div class="col-sm-6">
                      <label class="radio-inline">
                        <input  name="domain" type="radio" value="0" checked>关闭</label>
                      <label class="radio-inline">
                        <input name="domain" type="radio" value="1">开启</label>
                    </div>
                  </div>

                  <div class="form-group">
                    <label  class="col-sm-2 control-label">自动绑定</label>

                    <div class="col-sm-6">
                      <label class="radio-inline">
                        <input  name="autobinding" type="radio" value="0" checked disabled>关闭</label>
                      <label class="radio-inline">
                        <input name="autobinding" type="radio" value="1" disabled>开启</label>
                    </div>
                  </div>

                  <div class="form-group">
                    <label for="min_money" class="col-sm-2 control-label">结算最小金额(元)</label>

                    <div class="col-sm-6">
                      <input type="number" class="form-control" id="min_money">
                    </div>
                  </div>

                  <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                      <button  onclick="sumbitForm(1);" type="button" class="btn btn-primary">保存设置</button>
                    </div>
                  </div>
                </form>
              </div>
              <div class="tab-pane" id="serve">
                <form class="form-horizontal">
                  <div class="form-group">
                    <label for="jsServer" class="col-sm-2 control-label">js服务器</label>
                    <div class="col-sm-6">
                      <input type="text" class="form-control" id="jsServer">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="sdkServer" class="col-sm-2 control-label">SDK服务器</label>
                    <div class="col-sm-6">
                      <input type="text" class="form-control" id="sdkServer">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="picServer" class="col-sm-2 control-label">图片服务器</label>
                    <div class="col-sm-6">
                      <input type="text" class="form-control" id="picServer">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="jumpServer" class="col-sm-2 control-label">跳转服务器</label>
                    <div class="col-sm-6">
                      <input type="text" class="form-control" id="jumpServer">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="sdkJumpServer" class="col-sm-2 control-label">SDK跳转服务器</label>
                    <div class="col-sm-6">
                      <input type="text" class="form-control" id="sdkJumpServer">
                    </div>
                  </div>
                  <!--<hr/>
                  <div class="form-group">
                    <label for="lyios" class="col-sm-2 control-label">联运平台ios下载地址前缀</label>
                    <div class="col-sm-6">
                      <input type="text" class="form-control" id="lyios">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="lyandroid" class="col-sm-2 control-label">联运平台android下载地址前缀</label>
                    <div class="col-sm-6">
                      <input type="text" class="form-control" id="lyandroid">
                    </div>
                  </div>-->

                  <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                      <button onclick="sumbitForm(2);" type="button" class="btn btn-primary">保存设置</button>
                    </div>
                  </div>
                </form>
              </div>
              <div class="tab-pane" id="kou">
                <form class="form-horizontal">
                  <div class="form-group">
                    <label for="inputCpc" class="col-sm-2 control-label">CPC扣量(%)</label>
                    <div class="col-sm-6">
                      <input type="text" class="form-control" id="inputCpc">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="inputCpa" class="col-sm-2 control-label">CPA扣量(%)</label>
                    <div class="col-sm-6">
                      <input type="text" class="form-control" id="inputCpa">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="inputCpm" class="col-sm-2 control-label">CPM扣量(%)</label>
                    <div class="col-sm-6">
                      <input type="text" class="form-control" id="inputCpm">
                    </div>
                  </div>

                  <div class="form-group">
                    <label for="inputXrate" class="col-sm-2 control-label">下线分成比例(%)</label>
                    <div class="col-sm-6">
                      <input type="text" class="form-control" id="inputXrate">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="charges" class="col-sm-2 control-label"> 手续费(%)</label>
                    <div class="col-sm-6">
                      <input type="text" class="form-control" id="charges">
                    </div>
                  </div>


                  <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                      <button onclick="sumbitForm(3);" type="button" class="btn btn-primary">保存设置</button>
                    </div>
                  </div>
                </form>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>
  </div>
  <!--底部-->
  <footer id="footerDiv" class="main-footer">
    <!--#include  file="/pages/admin/footer.html"-->
  </footer>

  <!-- Control Sidebar -->
  <!-- /.control-sidebar -->
  <!-- Add the sidebar's background. This div must be placed
       immediately after the control sidebar -->
  <div class="control-sidebar-bg"></div>
</div>
<script src="/bower_components/jquery/dist/jquery.min.js"></script>
<script src="/bower_components/morris.js/morris.min.js"></script>
<script src="/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="/bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
<script src="/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
<script src="/bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<script src="/bower_components/fastclick/lib/fastclick.js"></script>
<script src="/dist/js/adminlte.min.js"></script>

<script src="/dist/js/layer/layer.js"></script>

<script>
    $(function () {
      //加载初始化数据
        let url="/lmgame/set/initSetting";
        $.ajax({
            type : 'POST',
            url : url,
            data :{},
            dataType : "json",
            success: function(data) {
                data=data.data;
                $("#sysName").val(data.sys_name);
                if(data.add_site=="0"){
                    $("input[name='addSite'][value='0']").attr("checked",true);
                }else{
                    $("input[name='addSite'][value='1']").attr("checked",true);
                }

                if(data.domain=="0"){
                    $("input[name='domain'][value='0']").attr("checked",true);
                }else{
                    $("input[name='domain'][value='1']").attr("checked",true);
                }

                if(data.autobinding=="0"){
                    $("input[name='autobinding'][value='0']").attr("checked",true);
                }else{
                    $("input[name='autobinding'][value='1']").attr("checked",true);
                }

                $("#register").val(data.reg_limit);
                $("#pvStep").val(data.pv_step);
                $("#min_money").val(data.min_money);//允许结算最小金额



                $("#jsServer").val(data.js_server);
                $("#sdkServer").val(data.sdk_server);
                $("#picServer").val(data.pic_server);
                $("#jumpServer").val(data.jump_server);
                $("#sdkJumpServer").val(data.sdk_jump_server);
                // $("#lyios").val(data.lyios);
                // $("#lyandroid").val(data.lyandroid);


                $("#inputCpc").val(data.kou_cpc);
                $("#inputCpa").val(data.kou_cpa);
                $("#inputCpm").val(data.kou_cpm);
                $("#inputXrate").val(data.xmoney_rate);
                $("#charges").val(data.charges);
            },
            error: function (xhr, ts, et) { //XMLHttpRequest, textStatus, errorThrown
                if (xhr.status === 400) {
                    window.location.href = "/pages/admin/login.html";
                }
                if (xhr.status === 403) {
                    window.location.href = "/403.html";
                }
            }
        });

    });
var flag=true;
    function sumbitForm(type) {
        if(!flag){
            return;
        }
        flag=false;
        let sysName = $("#sysName").val();

        let addSite = $("input[name='addSite']:checked").val();

        let register = $("#register").val();
        let pvStep = $("#pvStep").val();
        let domain = $("input[name='domain']:checked").val();

        let min_money=$("#min_money").val();


        let jsServer = $("#jsServer").val();
        let sdkServer = $("#sdkServer").val();
        let picServer = $("#picServer").val();
        let jumpServer = $("#jumpServer").val();
        let sdkJumpServer = $("#sdkJumpServer").val();
        // let lyios = $("#lyios").val();
        // let lyandroid = $("#lyandroid").val();


        let inputCpc = $("#inputCpc").val();
        let inputCpa = $("#inputCpa").val();
        let inputCpm = $("#inputCpm").val();
        let inputXrate = $("#inputXrate").val();
        let charges = $("#charges").val();

        let data='';
        if(type===1){
            data={"sysName":sysName,"addSite":addSite,"register":register,"pvStep":pvStep,"domain":domain,"min_money":min_money};
        }else if(type===2){
            data={"jsServer":jsServer,"sdkServer":sdkServer,"picServer":picServer,"jumpServer":jumpServer,"sdkJumpServer":sdkJumpServer};
        }else if(type===3){
            data={"inputCpc":inputCpc,"inputCpa":inputCpa,"inputCpm":inputCpm,"inputXrate":inputXrate,"charges":charges};
        }
        let url="/lmgame/set/saveSetting";
        $.ajax({
            type : 'POST',
            url : url,
            data :data,
            dataType : "json",
            success: function(data) {

                if (data.code != 0) {
                    layer.msg(data.msg);
                } else {
                    layer.msg('保存成功');
                    flag=true;
                }
            },
            error:function (data) {
                flag=true;
            }
        });


    }
</script>
</body>
</html>
